from django.shortcuts import render
from django_filters import FilterSet,filters
from rest_framework.pagination import PageNumberPagination
from rest_framework import viewsets
from django_filters.rest_framework import DjangoFilterBackend
from teacher import models,teacher_serializer
# Create your views here.



class Mypage(PageNumberPagination):
    page_size_query_param = 'size'

class MyFilter(FilterSet):
    starttime=filters.DateFilter(field_name='starttime',lookup_expr='gte')
    endtime=filters.DateFilter(field_name='endtime',lookup_expr='lte')
    class Meta:
        fields = ['name','department']
        model = models.StaffModel

class Department(viewsets.ModelViewSet):
    queryset = models.DepartmentModel.objects.all()
    serializer_class = teacher_serializer.DepartmentSer


class Staff(viewsets.ModelViewSet):
    queryset = models.StaffModel.objects.all()
    serializer_class = teacher_serializer.StaffSer

    filter_backends = [DjangoFilterBackend]
    pagination_class = Mypage
    filterset_class=MyFilter


